<?php
namespace App\Http\Controllers\Partner;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\PartnerModels\Partner;
use App\Models\AdminModels\Industry;
use App\Models\AdminModels\Config;
use App\Models\OrderModels\Order;
class PartnerController extends Controller{

    //实名审核列表
    public function realindex(){
        return view( 'partner/realName/index',['void_real_data'=>true]);
    }
    public function consultingLndex(){
        return view('partner/consulting/index',['admin_consulting_menu'=>true]);
    }
    //实名列表
    public function reallist(){
        return view( 'partner/realName/info',['void_real_info'=>true]);
    }
    //轮播图页面
    public function photoLndex(){
        return view('partner/consulting/photo',['admin_photo_menu'=>true]);
    }
	//合伙人列表
	public function index(){
		$partner_discount=\App\Components\Tools::getOneconfig('/config/config.json',array('basics','partner_discount'));
		return view('partner/partner/index',['admin_partner_menu'=>true,'partner_discount'=>$partner_discount]);
	}
	//添加合伙人页面
	public function create(){
		$partner_discount=\App\Components\Tools::getOneconfig('/config/config.json',array('basics','partner_discount'));
		
		$oIndustry = new Industry();
		$industries = $oIndustry->getAllData();
		return view('partner/partner/create',['admin_partner_menu'=>true,'industries'=>$industries,'partner_discount'=>$partner_discount]);
	}
	
	//修改合伙人页面
	public function edit($id){
		$partner_discount=\App\Components\Tools::getOneconfig('/config/config.json',array('basics','partner_discount'));
		if(intval($id) > 0){
			$orderinfo=new Order();
			$orderlist=$orderinfo->selectOne(array('partner_id'=>$id,'type'=>3));
			
			$oPartner = new Partner();
			$data = $oPartner->db_get(['id'=>['=',$id]]);
			if(!empty($data)){
				$oIndustry = new Industry();
				$industries = $oIndustry->getAllData();
			}
			return view('partner/partner/edit',['admin_partner_menu'=>true,'data'=>$data,'industries'=>$industries,'orderlist'=>$orderlist,'partner_discount'=>$partner_discount]);
		}
		abort(404);
	}
	
	//查看合伙人详情
	public function view($id){
		$oPartner = new Partner();
		$config=Config('basics.pay_type');
		if(intval($id) > 0){
			$values=array(
				'a.id'=>$id,
				'a.type'=>1,
				'b.type'=>3
			);
			$data=$oPartner->listOne($values);
			if($data){
				$data['pay_type_name']=$config[$data['pay_type']];
				if($data['gender']==1){
					$data['gender']="男";
				}elseif($data['gender']==2){
					$data['gender']="女";
				}else{
					$data['gender']="未知";
				}
				if($data['status']==1){
					$data['status']="开启";
				}elseif($data['status']==0){
					$data['status']="关闭";
				}else{
					$data['status']="已删除";
				}
			}
			return view('partner/partner/view',['admin_partner_menu'=>true,'data'=>$data]);
		}
		abort(404);
	}
	
}
